String_Enc = require "String_Enc/init"
Others = require "Others/init"
Defense = require "Defense/init"

menu = {
	"选择脚本",
	"输出路径",
	"字符串加密",
	"添加防御",
	}
menu_default = {
	gg.getFile(),
	gg.getFile(),
	true,
	true,
	}
menu_style = {
	"file",
	"path",
	"checkbox",
	"checkbox",
	}

for key, value in pairs(Other_Pattern) do
	table.insert(menu, value)
	table.insert(menu_default, false)
	table.insert(menu_style, "checkbox")
end

info = gg.prompt(menu,menu_default,menu_style)

if info ~= nil then
	file = io.open(info[1],"r")
	code = file:read("*a")
	file:close()

	if info[3] == true then
		code = _ENV[String_Enc](code)
	end
	if info[4] == true then
		for key, value in pairs(Defense) do
			code = "\n"..value.."\n"..code
		end
	end
	if info[5] == true then
		code = _ENV[Other_Pattern_func[1]](code)
	end

	path = info[1]:gsub(".-%/","")
	if info[2]:sub(info[2]:len(),info[2]:len()) ~= "//" then
		path = info[2].."/"..path
	else
		path = info[2]..path
	end

	file = io.open(path..".bin","w+")
	file:write(code)
	file:close()
end
